﻿/***
**异步加载器
***/
var loader = {
	enable: true,
	pageIndex: 1,
	skip: 0,
	show: function (datas, status) {
		window.append(datas);
		//this.sleep();
	},

	sleep: function () {
		_this = this;
		this.enable = false,
	setTimeout(function () { _this.enable = true; }, 2000);
	},

	loading: function (_url, parameter) {
		var _this = this;
		$.ajax({ type: "get", dataType: "json", data: parameter, url: _url,

			/*ajax调用之前*/
			beforeSend: function (XMLHttpRequest) {
				_this.beforeSend(XMLHttpRequest);
			},

			/**ajax调用成功之后**/
			success: function (data, textStatus) {
				_this.show(data, textStatus);
			},

			/*发生错误的处理*/
			error: function (XMLHttpRequest, textStatus, errorThrown) {
				_this.showError(XMLHttpRequest, textStatus, errorThrown);
				//请求出错处理
			}
		});
	},

	/*加载之前可以抛出一朵菊花*/
	beforeSend: function () {
		/*空接口*/
	},
	showError: function (XMLHttpRequest, textStatus, errorThrown) {
		//alert(textStatus || errorThrown);
	}
};
